package com.bwjf.authority.biz.impl;

import com.bwjf.authority.entity.AuthorityUser;
import com.bwjf.authority.mapper.AuthorityUserMapper;
import com.bwjf.authority.biz.AuthorityUserBiz;
import com.bwjf.authority.commons.base.entity.ResultData;
import com.bwjf.authority.commons.base.entity.ResultMsg;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author LiLuQing
 * @since 2017-03-06
 */
@Service
public class AuthorityUserBizImpl extends ServiceImpl<AuthorityUserMapper, AuthorityUser> implements AuthorityUserBiz {
    
    private AuthorityUser getAuthorityUserByCodePassword(AuthorityUser user){
        String password=DigestUtils.md5Hex(user.getUserPassword());//密文
        user.setUserPassword(password);
        user=baseMapper.selectOne(user);
        return user;
    }
    
    /**
     * 登录
     * @param user
     * @return
     */
    @Override
    public ResultData<AuthorityUser> login(AuthorityUser user){
        user=getAuthorityUserByCodePassword(user);
        return new ResultData<AuthorityUser>(user!=null, "登录成功！", "登录失败，用户名或密码错误！", user);
    }
    
}
